In a power transistor that performs switching operation at high speed, a surge voltage may be generated due to a parasitic inductance, for example, at the time when the power transistor is turned off. If a surge voltage is generated, the gate insulating film is destroyed, or ringing occurs in the circuit, which is a problem. Surge voltage is difficult to detect since it has a high voltage and occurs in a short time.